<%--
  Created by IntelliJ IDEA.
  User: Misterchaos
  Date: 2019-07-17
  Time: 下午 04:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>ticket</title>
    <script>
        function cancelTicket(order_id) {
            if(confirm('是否确认退票?')){
                window.location.href="http://localhost:8080/ticket/ticket/ticket?method=delete.do&order_id="+order_id;
            }else {
                return;
            }
        }
    </script>

</head>
<body>
<h1 style="text-align: center">火车票网上售票系统</h1>
<hr>
<h3>当前登陆用户：[ ID = ${sessionScope.login.getId()}][LEVEL = ${sessionScope.login.getType()}] <a
        href="http://localhost:8080/ticket/ticket/ticket?method=list.do&scope=mine&page=1">我的订单</a>
    |<a href="http://localhost:8080/index.jsp?method=search">查询车票</a>|<a
            href="http://localhost:8080/ticket/ticket/ticket?method=list.do&scope=record&page=1">抢票记录</a>|
    <a href="http://localhost:8080/ticket/ticket/user?method=logout.do">退出登陆</a>
</h3>
<c:if test="${param.method=='search'}">
    <form action="http://localhost:8080/ticket/ticket/ticket?">
        始发站：<input type="text" name="origin">
        终点站：<input type="text" name="destination">
        车次编号：<input type="text" name="number">
        <input type="text" name="method" value="list.do" style="display: none;">
        <input type="text" name="page" value="1" style="display: none;">
        <input type="submit" value="search">
    </form>
</c:if>
<c:if test="${requestScope.record_list!=null}">
    <c:forEach var="i" begin="1" end="${requestScope.record_list.size()}">
        <h3>车票id:${requestScope.record_list.get(i-1).getTicketId()} |
            状态：${requestScope.record_list.get(i-1).getResult()} |
            时间：${requestScope.record_list.get(i-1).getGmtCreate()}</h3>
        <hr>
        <%--        <div>--%>
        <%--            <h3>${requestScope.record_list.get(i-1).getNumber()} : ${requestScope.record_list.get(i-1).getOrigin()}--%>
        <%--                TO ${requestScope.record_list.get(i-1).getDestination()}--%>
        <%--                    ${requestScope.record_list.get(i-1).getPrice()}元--%>
        <%--                <a href="http://localhost:8080/ticket/ticket/ticket?method=delete.do&ticket_id=${requestScope.record_list.get(i-1).getTicketId()}">退票</a>--%>
        <%--            </h3>--%>
        <%--            <p>发车时间 ：${requestScope.record_list.get(i-1).getDepart()}  到站时间： ${requestScope.record_list.get(i-1).getArrive()}</p>--%>
        <%--            <hr>--%>
        <%--        </div>--%>
    </c:forEach>
</c:if>
<c:if test="${requestScope.ticket_list!=null}">
    <c:forEach var="i" begin="1" end="${requestScope.ticket_list.size()}">
        <div>
            <h3>${requestScope.ticket_list.get(i-1).getNumber()} : ${requestScope.ticket_list.get(i-1).getOrigin()}
                TO ${requestScope.ticket_list.get(i-1).getDestination()}
                    ${requestScope.ticket_list.get(i-1).getPrice()}元 余票：
                    ${requestScope.ticket_list.get(i-1).getInventory()}
                <a href="http://localhost:8080/ticket/ticket/ticket?method=buy.do&ticket_id=${requestScope.ticket_list.get(i-1).getId()}">抢票</a>
            </h3>
            <p>发车时间 ：${requestScope.ticket_list.get(i-1).getDepart()}
                到站时间： ${requestScope.ticket_list.get(i-1).getArrive()}</p>
            <hr>
        </div>
    </c:forEach>
</c:if>
<c:if test="${requestScope.order_list!=null}">
    <c:forEach var="i" begin="1" end="${requestScope.order_list.size()}">
        <div>
            <h3>${requestScope.order_list.get(i-1).getNumber()} : ${requestScope.order_list.get(i-1).getOrigin()}
                TO ${requestScope.order_list.get(i-1).getDestination()}
                    ${requestScope.order_list.get(i-1).getPrice()}元
                <a href="#" onclick="cancelTicket(${requestScope.order_list.get(i-1).getId()})">退票</a>
            </h3>
            <p>发车时间 ：${requestScope.order_list.get(i-1).getDepart()}
                到站时间： ${requestScope.order_list.get(i-1).getArrive()}</p>
            <hr>
        </div>
    </c:forEach>
</c:if>

</body>
</html>
